import os

# 数据库配置
Database_type = 'mysql'
Database_driver = 'pymysql'
Database_username = 'root'
Database_password = os.getenv('DATABASE_PASSWORD')
Database_host = '127.0.0.1'
Database_port = '3306'
Database_name = 'bluelog'
SQLALCHEMY_DATABASE_URI = '{}+{}://{}:{}@{}:{}/{}?charset=utf8'.format(Database_type, Database_driver, Database_username, Database_password, Database_host, Database_port, Database_name)

basedir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


class BaseConfig(object):
    SECRET_KEY = os.getenv('SECRET_KEY', 'secret string')  # 密钥配置

    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 数据库追踪
    SQLALCHEMY_RECORD_QUERIES = True  # 启用慢查询记录功能

    DEBUG_TB_INTERCEPT_REDIRECTS = False  # DEBUG调试工具

    CKEDITOR_ENABLE_CSRF = True  # 富文本编辑设置
    CKEDITOR_FILE_UPLOADER = 'admin.upload_image'

    MAIL_SERVER = os.getenv('MAIL_SERVER')  # 发邮件设置
    MAIL_PORT = 465
    MAIL_USE_SSL = True
    MAIL_USERNAME = os.getenv('MAIL_USERNAME')
    MAIL_PASSWORD = os.getenv('MAIL_PASSWORD')
    MAIL_DEFAULT_SENDER = (u'黑猪', MAIL_USERNAME)
    EMAIL_TO = os.getenv('EMAIL_TO')

    BLUELOG_POST_PER_PAGE = 10  # 分页管理
    BLUELOG_MANAGE_POST_PER_PAGE = 15
    BLUELOG_COMMENT_PER_PAGE = 15

    BLUELOG_THEMES = {'perfect_blue': 'Perfect Blue', 'black_swan': 'Black Swan'}
    BLUELOG_SLOW_QUERY_THRESHOLD = 1

    BLUELOG_UPLOAD_PATH = os.path.join(basedir, 'uploads')
    BLUELOG_ALLOWED_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif']


class DevelopmentConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = SQLALCHEMY_DATABASE_URI


config_dict = {
    'development': DevelopmentConfig
}